package com.yangjicong.o2o.studey.base.common.exception;

import com.yangjicong.o2o.studey.base.common.enums.ErrorCodeEnum;
import lombok.Getter;

/**
 * @author: yangwenhui
 * @date: 2019/1/15
 * @description:
 */
public class ServiceException extends RuntimeException{

    @Getter
    private final ErrorCodeEnum errorCodeEnum;

    /**
     *
     * @param errorCodeEnum 错误编号
     */
    public ServiceException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getErrorDesc());
        this.errorCodeEnum = errorCodeEnum;
    }

    /**
     *
     * @param errorCodeEnum 错误编号
     * @param errorDesc 错误信息
     */
    public ServiceException(ErrorCodeEnum errorCodeEnum, String errorDesc) {
        super(errorDesc);
        this.errorCodeEnum = errorCodeEnum;
    }


    @Override
    public final String toString() {
        return getClass().getName() + ":" + errorCodeEnum + "[" + getMessage() + "]";
    }


}
